package com.wewins.fota.sys.config;

import ch.qos.logback.core.joran.spi.NoAutoStart;
import ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.time.Duration;

@NoAutoStart
public class LogbackRollingConfig<E> extends SizeAndTimeBasedFNATP<E> {
    @Getter
    @Setter
    private String timeGap;

    @Override
    protected void computeNextCheck() {
        if (StringUtils.isEmpty(this.timeGap)) {
            timeGap = "p1d";
        }
        Duration duration = Duration.parse(timeGap);
        nextCheck = System.currentTimeMillis() + duration.toMillis();
    }

}
